|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectcontrolP5.Controller
controlP5.Textfield
public class Textfield
description for singleline textfield. create a texfield with
controlP5.addTextfield(theName,theX,theY,theWidth,theHeight);
the Textfield implementation for ControlP5 tries its best to imitate the
usage and behavior of a terminal, the command line.
/**
* ControlP5 Textflied.
*
* for a more advanced example see textfieldAdvanced which
* demonstrates how to use keepFocus, setText, getText, getTextList,
* clear, setAutoClear, isAutoClear or submit.
* by andreas schlegel, 2009
*/
import controlP5.*;
ControlP5 controlP5;
String textValue = "";
Textfield myTextfield;
void setup() {
size(400,400);
frameRate(25);
controlP5 = new ControlP5(this);
myTextfield = controlP5.addTextfield("texting",100,160,200,20);
myTextfield.setFocus(true);
controlP5.addTextfield("textValue",100,200,200,20);
}
void draw() {
background(0);
}
void controlEvent(ControlEvent theEvent) {
println("controlEvent: accessing a string from controller '"+theEvent.controller().name()+"': "+theEvent.controller().stringValue());
}
public void texting(String theText) {
// receiving text from controller texting
println("a textfield event for controller 'texting': "+theText);
}
| Field Summary |
|---|
| Fields inherited from interface controlP5.ControlP5Constants |
|---|
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE, VERTICAL |
| Constructor Summary | |
|---|---|
Textfield(ControlP5 theControlP5,
ControllerGroup theParent,
java.lang.String theName,
java.lang.String theDefaultValue,
int theX,
int theY,
int theWidth,
int theHeight)
|
|
| Method Summary | |
|---|---|
void |
addToXMLElement(ControlP5XMLElement theElement)
|
void |
clear()
clear the current content of the textfield. |
void |
draw(processing.core.PApplet theApplet)
the default draw function for each controller extending superclass Controller. |
java.lang.String |
getText()
get the current text of the textfield. |
java.lang.String[] |
getTextList()
returns a string array that lists all text lines that have been confirmed with a return. |
boolean |
isAutoClear()
returns the current state of the autoClear flag. |
boolean |
isFocus()
check if the textfield is active and in focus. |
void |
keepFocus(boolean theFlag)
use true as parameter to force the textfield to stay in focus. |
void |
keyEvent(java.awt.event.KeyEvent theKeyEvent)
flip throught the texfield history with cursor keys UP and DOWN. |
void |
setAutoClear(boolean theFlag)
use setAutoClear(false) to not clear the content of the textfield after confirming with return. |
void |
setFocus(boolean theFlag)
set the textfield's focus to true or false. |
void |
setPasswordMode(boolean theFlag)
set the mode of the textfield to password mode, each character is shown as a "*" like e.g. |
void |
setText(java.lang.String theValue)
setText does set the text of a textfield, but will not broadcast its value. |
void |
setValue(float theValue)
set the value of the controller. |
void |
setValue(java.lang.String theValue)
set the value of the textfield and will broadcast the new string value immediately. |
void |
submit()
make the controller execute a return event. |
void |
update()
updates the value of the controller without having to set the value explicitly. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Textfield(ControlP5 theControlP5,
ControllerGroup theParent,
java.lang.String theName,
java.lang.String theDefaultValue,
int theX,
int theY,
int theWidth,
int theHeight)
theControllerProperties - ControllerProperties| Method Detail |
|---|
public void setValue(float theValue)
Controller
setValue in class ControllertheValue - floatpublic void setPasswordMode(boolean theFlag)
theFlag - booleanpublic void setFocus(boolean theFlag)
theFlag - booleanpublic void keepFocus(boolean theFlag)
theFlag - public boolean isFocus()
public void setValue(java.lang.String theValue)
theValue - Stringpublic void setText(java.lang.String theValue)
theValue - public void update()
Controller
update in interface ControllerInterfaceupdate in class Controllerpublic void draw(processing.core.PApplet theApplet)
Controller
draw in interface CDrawabledraw in interface ControllerInterfacedraw in class ControllertheApplet - PAppletControllerDisplaypublic void keyEvent(java.awt.event.KeyEvent theKeyEvent)
keyEvent in interface ControllerInterfacekeyEvent in class ControllertheKeyEvent - KeyEventpublic java.lang.String getText()
public java.lang.String[] getTextList()
public void clear()
public void setAutoClear(boolean theFlag)
theFlag - public boolean isAutoClear()
public void submit()
public void addToXMLElement(ControlP5XMLElement theElement)
theElement - ControlP5XMLElement
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||